package com.lagou.edu.utils;

import com.alibaba.druid.pool.DruidDataSource;

/**
 * @author Kirito
 * @description:
 * @date 2020/04/04
 */
public class DruidUtils {

    private DruidUtils() {
    }

    private static DruidDataSource dataSource = new DruidDataSource();

    static {
        //InputStream inputStream = null;
        //try {
        //inputStream = DruidUtils.class.getResourceAsStream("jdbc.properties");
        //Properties properties = new Properties();
        //properties.load(inputStream);
        //dataSource.setDriverClassName(properties.getProperty("jdbc.driver"));
        // dataSource.setUrl(properties.getProperty("jdbc.url"));
        //dataSource.setUsername(properties.getProperty("jdbc.username"));
        //dataSource.setPassword(properties.getProperty("jdbc.password"));
        //} catch (IOException e) {
        //    e.printStackTrace();
        //}

        dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
        dataSource.setUrl("jdbc:mysql://localhost:3306/learn_mybatis?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=UTC");
        dataSource.setUsername("root");
        dataSource.setPassword("root");
    }

    public static DruidDataSource getInstance() {
        return dataSource;
    }

}
